<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
  <head>
    <link href="<s:url value="/resources"/>/css/style_new.css" rel="stylesheet" type="text/css" />
    <link href="<s:url value="/resources"/>/css/main_new.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script>  
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script> 
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
<style>
html, body {
	margin: 0;			 
	padding: 0;
    font-size: 85%;
}
</style>
    <script>
    var qieye = 0;
	$(function() {
	loadTab(0);
	$("#chax").button();
	$("#reset").button();
	//$("#excel").button();
	$( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    $( "#datepicker1" ).datepicker($.datepicker.regional[ "zh-CN" ]);    
		$( "#tabs" ).tabs({
			select: function(event, ui) {
		    var i =ui.index;
		    //alert(i);	    
		    if(i==''){
		    i="0";
		    }
		    qieye = i;
		    //alert(qieye);
		    loadTab(i);		    
		    //$("#myTab"+i).jqGrid('setGridParam',{url:'htspJqgrid.action?spzt='+i,mtype:'post',page:1}).trigger("reloadGrid");		   
		             
            //return false;
           }
		});
	
	});
	 function loadTab(i){  
    $("#myTab"+i).jqGrid({      
    url:'findZgqrGrid?index='+i,   
    datatype: 'json',
    mtype: 'post', 
    altRows: true,         
   	colNames:['操作','订单编号','订单类型','年份', '月份','发货单位', '省部','收货单位','发站','到站','吨数','车数','订单状态','dingdid'],
   	colModel:[ 
   	    {name:'Verify',index:'id',width:60,align:"center",sortable:false},
   	    {name:'dingdbh',index:'dingdbh', width:120},
   	    {name:'ddlx',index:'ddlx', width:60},	  		
   		{name:'nianf',index:'nianf', width:60},
   		{name:'yuef',index:'yuef', width:60},
   		{name:'fahdwmch',index:'fahdwmch', width:200},
   		{name:'fahdwshb',index:'fahdwshb', width:60 },
   		{name:'shouhdwmch',index:'shouhdwmch', width:200 },
   		{name:'fazhmch',index:'fazhmch', width:60 },	
   		{name:'daozh',index:'daozh', width:60 },	
   		{name:'huowdsh',index:'huowdsh', width:60 },
   		{name:'chesh',index:'chesh', width:60 },
   		{name:'dingdzht',index:'dingdzht', width:50, sortable:false},
   		{name:'dingdid',index:'dingdid'}		
   	],
   
    jsonReader: {
           repeatitems : false, 
           id: 'dingdid'
         }, 
    width: 1200, 
    shrinkToFit:false,   	
   	rowNum:10,
   	rowList:[10,20,30],     	
   	pager: '#pager'+i,
   	rownumbers: true,   	 
    viewrecords: true,
    sortorder: 'desc',
    multiselect: true, 
    altRows:true, 
    //multiselect: true  
	//caption: "合同列表"	
	gridComplete:function()
	{ //在此事件中循环为每一行添加修改和删除链接 
		var ids=jQuery("#myTab"+i).jqGrid('getDataIDs'); 
		//alert(ids);
		for(var j=0; j<ids.length; j++)
		{ 
			var id=ids[j]; 
			//alert(id.hetbh);
			var verify ="";
			if(i==0){
			  verify ="<a href='#' style='color:#f60' onclick='Verify("+ id +")'>确认</a>"; 
			}else{
			  verify ="<a href='#' style='color:#f60' onclick='query("+ id +")'>查看</a>";
			}
			jQuery("#myTab"+i).jqGrid('setRowData',ids[j], { Verify: verify }); 
		} 
	} 
  });
 
  $("#myTab"+i).jqGrid('setGridHeight','280px');
  $("#myTab"+i).jqGrid('hideCol',["dingdzht"]);
  $("#myTab"+i).jqGrid('hideCol',["dingdid"]);
  }

  function openwindow(url){  
    var sheight = screen.height-70;
    var swidth = screen.width-10;
    var winoption ="dialogHeight:"+sheight+"px;dialogWidth:"+ swidth +"px;status:yes;scroll:yes;resizable:yes;center:yes";
    var result=window.showModalDialog(url,window,winoption);
    if(result ==1){
    reloadhtxx(); 
    }
   return result;  
}

  function reloadhtxx(){
   window.location.href="findJhspView";
}
  
   function Verify(id) {   
    //alert(id);
    var dingdid = "";
	if(id.id!=undefined){
	dingdid=id.id;
    }else{
    dingdid=id;
    }     
    openwindow('findZgqrDetail?dingdid='+dingdid+'&index='+qieye);
}

function query(id) {  
    //alert(id.id);
     var dingdid = "";
	if(id.id!=undefined){
	dingdid=id.id;
    }else{
    dingdid=id;
    }     
    openwindow('findJhcxDetail?dingdid='+dingdid+'&index='+qieye);
}

  // 查询
function search(){   
  var formdata = $("#form1").serialize(); 
 // alert(formdata); 
  $("#myTab"+qieye).jqGrid('setGridParam',{url:'findZgqrGrid?'+formdata+'&index='+qieye,mtype:'post',page:1}).trigger("reloadGrid"); 
}
  
function submitRow() {    
	var s = $("#myTab0").jqGrid('getGridParam','selarrrow');
	if (s == "") {
        alert("请先选择运力需求，再点击确认！");
        return;
    }
	var url = "<s:url value="/"/>/jhtb/reviewPLJhtb?ddid="+s;
	$( "#dialog-confirm1" ).dialog({
			resizable: false,
			height:140,
			modal: true,
			buttons: {
				"确认": function() {
				    
					$.post(url, function(data) {					
                    var json =eval('(' + data + ')');
					   if(json.result==1){					   
					   alert("确认成功！");
					   reloadhtxx();
					   }else{					  
					   alert("确认失败！");
					   }   
                   });                  
                   $( this ).dialog( "close" );
				},
				"返回": function() {
					$( this ).dialog( "close" );
				}
			}
		});       
}

function backRow() {    
	var s = $("#myTab0").jqGrid('getGridParam','selarrrow');
	if (s == "") {
        alert("请先选择运力需求，再点击批量退回！");
        return;
    }
	var url = "<s:url value="/"/>/jhtb/backJhqr?ddid="+s;
	$( "#dialog-confirm2" ).dialog({
			resizable: false,
			height:140,
			modal: true,
			buttons: {
				"确认": function() {
				    
					$.post(url, function(data) {					
                    var json =eval('(' + data + ')');
					   if(json.result==1){					   
					   alert("退回成功！");
					   reloadhtxx();
					   }else{					  
					   alert("退回失败！");
					   }   
                   });                  
                   $( this ).dialog( "close" );
				},
				"返回": function() {
					$( this ).dialog( "close" );
				}
			}
		});       
}

//excel
	function exportexcel(){ 
	  var formdata = $("#form1").serialize(); 
	  window.location.href("<s:url value="/jhtb"/>/excelForZgqr?"+formdata);
	
	}
	</script>
  </head>
  
  <body>
  <div class="container">
<div class="containerbox">
<div class="btn-bar"> 
 
    <a href="#" class="btn" onclick="submitRow();"><img src="<s:url value="/resources"/>/img/operate_pass.gif" /> <span>批量确认</span></a> 
    <a href="#" class="btn" onclick="backRow();"><img src="<s:url value="/resources"/>/img/ico_25.png" /> <span>批量退回</span></a>
    <a id="excel" href="#" class="btn" onclick="exportexcel();"><img src="<s:url value="/resources"/>/img/25.gif" /> <span>导出excel</span></a>
    </div>
 <div class="search mt10" id="list_search">  
<form id="form1" method="post">
<table class="search-table" width="90%" cellpadding="0" cellspacing="0" border="0"> 
        <tr>
        	<td> 
            	订单编号: 
            </td>
            <td>
            	<input type="text" name="aa" class="form-textbox" style="width: 200px;"/> 
            </td>
            <td>
                发货单位:
            </td>
            <td>
            <input type="text" name="bb" class="form-textbox" style="width: 200px;"/>	 
            </td>            
            <td>
               收货单位 :
            </td>
            <td>
            <input type="text" name="cc" class="form-textbox" style="width: 200px;"/>	
            </td>
        </tr>
        <tr>
        <td>发站(局):</td>
        <td><input type="text" name="dd" class="form-textbox" style="width: 200px;"/></td>
        <td>到站(局):</td>
        <td><input type="text" name="ee" class="form-textbox" style="width: 200px;"/></td>
        <td>合同编号:</td>
        <td><input type="text" name="ff" class="form-textbox" style="width: 200px;"/></td>
        </tr>        
        <tr>
        <td>吨数:</td>
        <td><input type="text" name="jj" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" />
          --
          <input type="text" name="kk" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" /></td>
        <td>车数:</td>
        <td><input type="text" name="ll" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" />
          --
          <input type="text" name="mm" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" /></td>
        <td>提报时间:</td>
            <td>
            <select name="nn" class="form-textbox" style="width: 93px;">
            <option value="" selected>==请选择==</option>
            <option value="2014">2014</option>
            <option value="2015">2015</option>
            <option value="2016">2016</option>
            </select>            
            	 --
            <select name="oo" class="form-textbox" style="width: 93px;">
            <option value="" selected>==请选择==</option>
            <option value="01">01</option>
            <option value="02">02</option>
            <option value="03">03</option>
            <option value="04">04</option>
            <option value="05">05</option>
            <option value="06">06</option>
            <option value="07">07</option>
            <option value="08">08</option>
            <option value="09">09</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            </select>
            </td>
        </tr>
        <tr>
        	<td> 
            	计划类型: 
            </td>
            <td>
            	<select name="pp" class="form-textbox" style="width: 93px;">
			          <option value="1" selected>月编计划</option>
			          <option value="2">日常计划</option>
			    </select>  
            </td>
        </tr>
        <tr>
    <td align="left" valign="middle" colspan="6">
<table border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td align="right" class="pr10 search-table-70">&nbsp;</td>
    <td align="left"><input name="" type="button" class="form-button-query form-button" value="查询" onclick="search();"/>
    <input name="" type="button" class="form-button-reset form-button" value="重置"  onclick="resetSearch();"/></td>
  </tr>
</table></td>
  </tr>
  </table> 
  </form>
  </div> 
   
    <div id="tabs">
	<ul>
		<li><a href="#tabs-0">待确认</a></li>
		<li><a href="#tabs-1">已确认</a></li>
		<li><a href="#tabs-2">已退回</a></li>
	</ul>
	<div id="tabs-0">  
		<table id="myTab0" class="scroll" cellpadding="0" cellspacing="0"></table>
		<div id="pager0" class="scroll"></div>  
        <div id="message0" class="scroll"></div> 
	</div>	
	<div id="tabs-1">  
		<table id="myTab1" class="scroll" cellpadding="0" cellspacing="0"></table>
		<div id="pager1" class="scroll"></div>  
        <div id="message1 " class="scroll"></div> 
	</div>
	<div id="tabs-2">  
		<table id="myTab2" class="scroll" cellpadding="0" cellspacing="0"></table>
		<div id="pager2" class="scroll"></div>  
        <div id="message2" class="scroll"></div> 
	</div>
	
   </div>
   <div id="dialog-confirm1" title="是否确认通过？"></div>
   <div id="dialog-confirm2" title="是否确认退回？"></div>
</div>
</div>
  </body>
</html>
